﻿using System;

namespace Grimgine.Math
{
    /// <summary>
    /// 
    /// </summary>
    public struct Ray : IEquatable<Ray>
    {
        #region Fields

        /// <summary>
        /// 
        /// </summary>
        public Vector3 Direction;

        /// <summary>
        /// 
        /// </summary>
        public Vector3 Position;

        #endregion

        #region Constructor

        /// <summary>
        /// 
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="position"></param>
        public Ray(Vector3 direction, Vector3 position)
        {
            Direction = direction;
            Position = position;
        }

        #endregion

        #region Comparison Methods

        /// <summary>
        /// 
        /// </summary>
        /// <param name="r1"></param>
        /// <param name="r2"></param>
        /// <returns></returns>
        public static bool operator ==(Ray r1, Ray r2)
        {
            return (r1.Direction == r2.Direction && r1.Position == r2.Position);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="r1"></param>
        /// <param name="r2"></param>
        /// <returns></returns>
        public static bool operator !=(Ray r1, Ray r2)
        {
            return !(r1 == r2);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            return obj is Ray && this == (Ray)obj;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="r1"></param>
        /// <returns></returns>
        public bool Equals(Ray r1)
        {
            return (this == r1);
        }

        #endregion

        #region Hash Code

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        #endregion
    }
}
